package org.nicocube.airain.gwt.client.ui;

import org.nicocube.airain.domain.client.character.Possession;
import org.nicocube.airain.domain.client.character.Possession.Type;
import org.nicocube.airain.gwt.client.AirainWeb;
import org.nicocube.airain.gwt.client.ui.item.ItemValued;
import org.nicocube.airain.gwt.client.ui.item.TableHeader;
import org.nicocube.airain.gwt.client.ui.item.TableOfItem;

import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;

public class PossessionsPanel extends AirainPanel {

	private FlowPanel myPanel;

	public Widget getLabel() {
		return 	new Label("Possessions",false);
	}
	
	public PossessionsPanel(AirainWeb aw) {
		super(aw);
		myPanel = new FlowPanel();

		TableOfItem<ItemValued> possessionTable = new TableOfItem<ItemValued>(
				new TableHeader()
				.addCols("Object")
				.addCols("Acquired")
		);

		for (Possession p : getAW().getGc().getPossessionByType(Type.food)) {
			possessionTable.addRows(
					new ItemValued()
					.setIdent(p.getType().toString())
					.addValue(p.getAcquired().toString())
			);
		}

		for (Possession p : getAW().getGc().getPossessionByType(Type.javelin)) {
			possessionTable.addRows(
					new ItemValued()
					.setIdent(p.getType().toString())
					.addValue(p.getAcquired().toString())
			);
		}
		
		myPanel.add(possessionTable.render());
		/*
		GWTCanvas canvas = new GWTCanvas(10,10,300,300);
		
		final ScheduleCanvasPainter scp = new ScheduleCanvasPainter(canvas);
		scp.draw();
		
		myPanel.add(canvas);
		*/
	}

	@Override
	public Panel getPanel() {
		return myPanel;
	}

	
}
